	package cn.edu.nju.software.zp13.core2.nodeDescriptorFactory;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import cn.edu.nju.software.zp13.core2.annotationParser.AnnotationParser;
import cn.edu.nju.software.zp13.core2.annotation.Element;
import cn.edu.nju.software.zp13.core2.annotation.TextNode;
import cn.edu.nju.software.zp13.core2.nodeDescriptor.NodeDescriptor;
import cn.edu.nju.software.zp13.core2.nodeDescriptor.NodeType;
import cn.edu.nju.software.zp13.core2.xmlNodeEntity.XmlNodeEntity;

public class SimpleElementNodeDescriptorFactory extends ElementNodeDescriptorFactory implements NodeDescriptorFactory{
	
	public SimpleElementNodeDescriptorFactory(Element elementAnnotation,Field f) {
		super(elementAnnotation,f);
	}

	@Override
	public NodeDescriptor generateNodeDescriptor(Field f, Method[] methods, XmlNodeEntity entity) {
		NodeDescriptor nd=new NodeDescriptor();
		nd.setNodeName(tagName);
//		nd.setEntity(entity);
//		nd.setField(f);
		nd.setType(NodeType.SimpleElement);
		for(Method m:methods){
			TextNode tn=m.getAnnotation(TextNode.class);
			if(tn!=null&&tagName.equals(tn.fatherTagName())){
//				nd.setMethod(m);
			}
		}
		return nd;
	}
	
	public NodeDescriptor generateNodeDescriptor(Field f, Method method, XmlNodeEntity entity) {
		NodeDescriptor nd=new NodeDescriptor();
		nd.setNodeName(AnnotationParser.getElementTagName(f));
		nd.setType(NodeType.SimpleElement);
		
		return nd;
	}
	
}
